﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class SrollManage : MonoBehaviour {


    [SerializeField, Tooltip("关卡按钮组件")]
    private GameObject[] gObject;
    [Tooltip("获取按钮上的脚本")]
    private CpManage cpManage;
    [Tooltip("获取已储存的关卡信息")]
    private ArrayList cpAryList;
    [SerializeField, Tooltip("获取返回按钮")]
    private Button returnButton;
    // Use this for initialization
    private void Start()
    {
        int index = 0;
        cpAryList = TextClass.Instance.Load(true);
        foreach (SaveScores ss in cpAryList)
        {
            
            if (ss.IsOPen == false) break;
            cpManage = gObject[index].GetComponent<CpManage>();
            cpManage.IsOpen = ss.IsOPen;
            index++;
        }
    }//初始化关卡界面
    public void Return()
    {
        if (SetMManager.Instance != null)
            SetMManager.Instance.PlayMusic(0);
        StartCoroutine(Wait());
    }

    private IEnumerator Wait()
    {
        yield return new WaitForSeconds(0.05f);
        SceneManager.LoadScene(0);
    }

    private void Update()
    {
        if (Input.GetKey(KeyCode.Escape))
        {
            UIshower.Instance.StartPlay(Nodeal.Quit);
            Time.timeScale = 0;
        }
    }
}
